<?php
namespace app\member\controller;

class Config extends Member
{

    /**
     * 基础设置 2017-10-15
     */
    public function config()
    {
        if (request()->isPost()) {
            $data = input('post.');
            $data['uid'] = UID;
            $data['duotu1'] = serializeMysql($data['duotu1']);
            $data['duotu2'] = serializeMysql($data['duotu2']);
            $res = dataUpdate(\tname::config, $data);
            if (!$res) {
                return ajaxFalse();
            }
            return ajaxSuccess();
        } else {
            $data = db(\tname::config)->where('uid', UID)->find();
            if (!empty($data)) {
                $data['duotu1'] = serializeMysql($data['duotu1'], 1);
                $data['duotu2'] = serializeMysql($data['duotu2'], 1);
            }
            $this->assign('data', $data);
            return $this->fetch();
        }
    }

    /**
     * 导入页面  导入的excel数据必须为纯文本格式	2017-10-15
     */
    public function import(){
        if(request()->isPost()){
            $pdata = input('post.');

            $data = getData('.'.$pdata['excelpath']);
            if(!$data[0]){
                return ajaxFalse($data[1]);
            }

            foreach($data[1] as $key=>$value){
                $list[] = $value;
            }
            session('list',$list);
            return ajaxSuccess();
        }else{
            return $this->fetch();
        }
    }
}